<?php
// +----------------------------------------------------------------------
// | 麦沃德科技赋能开发者，助力中小企业发展 
// +----------------------------------------------------------------------
// | Copyright (c) 2017～2024  www.wdadmin.cn    All rights reserved.
// +----------------------------------------------------------------------
// | Wdadmin系统产品软件并不是自由软件，不加密，并不代表开源，未经许可不可自由转售和商用
// +----------------------------------------------------------------------
// | Author: MY WORLD Team <bd@maiwd.cn>   www.wdadmin.cn
// +----------------------------------------------------------------------

namespace app\admin\validate\wddj\operation;

use think\Validate;

class CommissionRatio extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'platform_commission_ratio'=>'require|between:1,100',
        'driver_commission_ratio'=>'require|between:1,100|checkCommissionRatioTotal',
    ];
    /**
     * 提示消息
     */
    protected $message = [
        'platform_commission_ratio.between'     => '平台收益比例最大值不能大于100%',
        'driver_commission_ratio.between'     => '司机收益比例最大值不能大于100%',
    ];
    /**
     * 验证场景
     */
    protected $scene = [
        'edit'  => ['platform_commission_ratio','driver_commission_ratio'],
    ];

    protected function checkCommissionRatioTotal($value,$rule,$data)
    {
        $total = bcadd($data['platform_commission_ratio'],$value,2);
        if ($total > 100) {
            return '平台收益比例加司机收益比例总和不等大于100%';
        }
        return true;
    }




    
}
